const dbutil = require('../../../libs/MyDB');

module.exports = {

    //显示所有课程
    show_courses: async function() {
        let courseArr = [];
        await dbutil.multiSelect('study_course', ['course_id', 'ctitle', 'signup_number', 'ctype', 'collection_number'])
            .then(
                res => {
                    courseArr = res;
                }
            )
        return courseArr;
    },

    //添加课程
    add_course: async function(coursename, typename) {
        await dbutil.add('study_course', {
            ctitle: coursename,
            ctype: typename
        })
    },

    //删除课程
    delete_course: async function(course) {
        await dbutil.del('study_course', `ctitle="${course}"`);
    }
}

